home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 7: Sunsite / Linux Cubed Series 7 - Sunsite Vol 1.iso / system / admin / linuxcon.000 / linuxcon / linuxconf-1.6 / xconf / section.h < prev    next >
C/C++ Source or Header  |  1996-07-31  |  2KB  |  108 lines

  1. #pragma interface
  2. #ifndef SECTION_H
  3. #define SECTION_H
  4.  
  5. #include "../misc/misc.h"
  6. /*
  7.     A PAIRES simply associate a keyword with a value which is a string
  8. */
  9. class PAIRES: public ARRAY_OBJ{
  10. public:
  11.     char *keyw;
  12.     char *arg;            // Value on the same line as the keyword
  13.     /*~PROTOBEG~ PAIRES */
  14. public:
  15.     PAIRES (const char *keyword, const char *value);
  16.     virtual ~PAIRES (void);
  17.     /*~PROTOEND~ PAIRES */
  18. };
  19.  
  20. class OPTION: public PAIRES{
  21.     /*~PROTOBEG~ OPTION */
  22. public:
  23.     OPTION (const char *keyword, const char *value);
  24.     virtual OPTION *clone (void)const;
  25.     virtual void merge (const OPTION *src);
  26.     virtual void print (FILE *fout)const;
  27.     virtual int validate (char *msg);
  28.     /*~PROTOEND~ OPTION */
  29. };
  30.  
  31. class OPTIONS: public ARRAY{
  32.     /*~PROTOBEG~ OPTIONS */
  33. public:
  34.     OPTION *getitem (int no)const;
  35.     virtual void print (FILE *fout, int indent)const;
  36.     /*~PROTOEND~ OPTIONS */
  37. };
  38.  
  39.  
  40. struct SECTION_DISPATCH{
  41.     char *keyw;
  42.     OPTION (*screa_section)(const char *keyw,
  43.         const char *arg,
  44.         FILE *fin,
  45.         const char *fname,
  46.         int &noline);
  47.     SECTION_DISPATCH *subdisp;    // Which suboption are valid for
  48.                                 // for this section
  49. };
  50.  
  51. class SECTION: public OPTIONS{
  52. protected:
  53.     char *name;
  54.     /*~PROTOBEG~ SECTION */
  55. public:
  56.     SECTION (const char *_name);
  57.     virtual SECTION *clone (void)const;
  58.     const char *findarg (const char *keyw);
  59.     void print (FILE *fout, int indent)const;
  60.     int readdisp (FILE *fin,
  61.          const char *fname,
  62.          int &noline,
  63.          SECTION_DISPATCH disp[]);
  64.     int validate (char *msg);
  65.     virtual ~SECTION (void);
  66.     /*~PROTOEND~ SECTION */
  67. };
  68.  
  69. class SECTIONS: public ARRAY{
  70.     /*~PROTOBEG~ SECTIONS */
  71.     /*~PROTOEND~ SECTIONS */
  72. };
  73.  
  74. class COMMENTS: public SECTION{
  75.     /*~PROTOBEG~ COMMENTS */
  76. public:
  77.     COMMENTS (void);
  78.     void print (FILE *fout);
  79.     /*~PROTOEND~ COMMENTS */
  80. };
  81. class XCONFIG: public SECTION{
  82.     COMMENTS comments;    // Comments added to the Xconfig
  83.                         // while configuring
  84.                         // It tells mostly what was selected
  85.     SECTIONS tbsect;
  86.  
  87. //    struct {
  88. //        OPTION *section;
  89. //        OPTION *subopt;
  90. //        SECTION_DISPATCH *subdisp;
  91. //    } parsing;
  92.     /*~PROTOBEG~ XCONFIG */
  93. public:
  94.     XCONFIG (void);
  95.     void addcomment (const char *keyw,
  96.          const char *manuf_id,
  97.          const char *model_id);
  98.     const char *getcomment (const char *keyw);
  99.     void merge (const XCONFIG *src);
  100.     int print (FILE *fout, int indent);
  101.     int read (const char *fname);
  102.     void sort (void);
  103.     int write (const char *fname);
  104.     /*~PROTOEND~ XCONFIG */
  105. };
  106.  
  107. #endif
  108.